<html>
<style type="text/css">
body {font-family: Verdana, Arial, Helvetica, sans-serif;}
.c {margin:auto;text-align:center;clear:both;}
.l {width:49%;clear:both;float:left;text-align:right;}
.r {width:49%;float:right;text-align:left;}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Siła sygnału</title>
<script language="javascript" type="text/javascript">
<!--
var secs=0;
var delay = 1000;

startTimer();
function startTimer()
{
 if (secs==0)
 {
  secs=3;
  refreshData();
 }
 else
 {
  self.status = secs;
  secs = secs - 1;
 }
 self.setTimeout("startTimer()", delay);
}
function refreshData()
{
 var req;

 try {req = new XMLHttpRequest();} catch (e) {
  try {req = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {
   try {req = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {
    alert("Coś stara ta przelądarka...");
    return false;
   }
  }
 }

 req.open("GET", "/cgi-bin/signal.sh");

 req.onreadystatechange = function() {

  if (req.readyState == 4) {
   var line=req.responseText;
   var arr=(line.split(/,/));
   if(arr.length>3)
   {
    var p = (arr[2]*100/31).toFixed();
    document.getElementById('csq').innerHTML=p+'%';
    document.getElementById('precent').style.width=p+"%";
    var color = "red";
    if (p > 29) {color="orange"; }
    if (p > 45) {color="yellow"; }
    if (p > 61) {color="green"; }
    document.getElementById('precent').style.backgroundColor=color;
   }
  }
 }

 req.send(null);
}
//-->
</script>
</head>
<body>
<table style='width:100%;height:100%;'>
 <tr><td colspan=3 style='height:100px;'>&nbsp;</td></tr>
 <tr>
  <td>&nbsp;</td>
  <td style='width:600px; height:200px;'>
   <span class="l">Siła sygnału:</span><span id="csq" class="r"></span>
   <div style="float:left; margin:1%; width:98%; height:20px; border:1px solid #000000; background-color:transparent;">
    <div id="precent" style="float:left; background-color:black; border-right:1px solid #000000; height:100%; width:0%">&nbsp;</div>
   </div>
  </td>
  <td>&nbsp;</td>
 </tr>
 <tr><td colspan=3>&nbsp;</td></tr>
</table>
</body>
</html>
